﻿using System;

using NHibernate;
using NHibernate.Cfg;

namespace NHibernateDemo.Data
{
    /// <summary>
    /// Session管理类,session per request模式
    /// </summary>
    public class SessionHelper
    {
        public static readonly ISessionFactory SessionFactory;

        static SessionHelper()
        {
            SessionFactory = new Configuration()
                .Configure()
                .BuildSessionFactory();
        }

        public static ISession OpenSession()
        {
            return SessionFactory.OpenSession();
        }

        public static ISession GetCurrentSession()
        {
            return SessionFactory.GetCurrentSession();
        }
    }
}
